from django.shortcuts import render


from rest_framework import serializers
from rest_framework.generics import ListAPIView
from rest_framework.response import Response
from rest_framework.views import APIView

from activities.models import Activity


class ActivityListSerializer(serializers.ModelSerializer):
    class Meta:
        model = Activity
        fields = ["id", "bg_image", "title", "start", "city", "status"]

# /activities/
# 返回所有活动的列表
class ActivityListView(ListAPIView):
    queryset = Activity.objects.all().order_by('-start')
    serializer_class = ActivityListSerializer
    # def get(self, request):
    #     qs = Activity.objects.all()
    #     serializer = ActivityListSerializer(qs, many=True)
    #     return Response(serializer.data)
